package persistentie;

import java.util.HashMap;
import java.util.Map;

import domein.Continent;
import domein.Keuze;
import domein.Land;
import domein.Locatie;
import domein.Vraag;
import domein.Waarneming;

public class MapperFactory 
{	
	@SuppressWarnings("unchecked")
	private Map<Class, Mapper> map;
	
	private static MapperFactory instance;
	
	@SuppressWarnings("unchecked")
	private MapperFactory()
	{
		map = new HashMap<Class, Mapper>();
		map.put(Continent.class, (Mapper) new ContinentenMapper());
		map.put(Land.class, (Mapper) new LandenMapper());
		map.put(Locatie.class, (Mapper) new LocatiesMapper());
		map.put(Waarneming.class, (Mapper) new WaarnemingenMapper());
		map.put(Vraag.class, (Mapper) new VragenMapper());
		map.put(Keuze.class, (Mapper) new KeuzeMapper());
	}
	
	public static MapperFactory getInstance()
	{
		if (instance == null)
			instance = new MapperFactory();
		return instance;
	}
	
	@SuppressWarnings("unchecked")
	public Mapper getMapper( Class soort)
	{
		return map.get(soort);
	}
}
